<template>
  <div>
      <div class="goods" v-for="item in goodList" :key="item.value">
      <ul>
        <li>
          <div class="pic">
            <a href="#">
              <img v-bind:src="'/static/'+item.pictureUrl" alt>
            </a>
          </div>
          <div class="main">
            <div class="name">{{item.productName}}</div>
            <div class="else">
              <span>price:{{item.productprice}}</span>
            </div>
          </div>
        </li>
      </ul>
    </div>
    <div class="goods" v-for="item in goodsList" :key="item.value">
      <router-link v-bain:to="{path:'/details',params:{productId:item.id}}">
      <ul>
        <li>
          <div class="pic">
            <a href="#">
              <img v-bind:src="item.pictureUrl" alt>
            </a>
          </div>
          <div class="main">
            <div class="name">{{item.productName}}</div>
            <div class="else">
              <span>price:{{item.productPrice}}</span>
            </div>
          </div>
        </li>
      </ul>
      </router-link>
    </div>
    <!-- <div class="goods">
      <h3>{{goodList}}</h3>
      <h3>{{goodsList}}</h3>
    </div> -->
  </div>
</template>
<style lang="scss">
.goods {
  width: 48%;
  height: 250px;
  float: left;
  margin: 1% 1%;
  // background-color: #fcf;
}
.pic {
  width: 100%;
  height: 180px;
}
img {
  width: 100%;
  height: 100%;
}
.main {
  width: 100%;
  height: 70px;
}
.name {
  width: 100%;
  height: 40%;
  background-color: #fff;
  font-size: 20px;
  text-align: center;
}
.else {
  width: 100%;
  height: 60%;
  background-color: #fff;
  color: red;
  font-size: 22px;
  line-height: 35px;
  text-align: center;
}
</style>
<script>
import axios from 'axios'
export default {
  data(){
    return {
      goodsList:[],
      goodList:[]
    }
  },
  mounted:function(){
    this.getGoodList();
    this.getGoodsList();
  },
  methods:{
    getGoodList(){
      axios.get('/api/appData').then((result)=>{
        var res = result.data;
        console.log(res);
        this.goodList = res.data.result;
      });
    },
    getGoodsList(){
      axios.get('http://106.13.96.243:8080/Neuq_JavaWeb_war_exploded//ProductController/getAllProducts').then((result)=>{
        var res = result.data;
        console.log(res);
        this.goodsList = res;
      });
    }
  }
};
</script>
